FROM registry.cn-guangzhou.aliyuncs.com/csingo/golang:1.22.7-alpine3.20 as builder

COPY . /www

WORKDIR /www

RUN --mount=type=cache,target=/root/.cache/go-build \
    go build -v -o bin/runner -ldflags "-X 'gitee.com/csingo/cServer.version=`cat version`'" server/main.go \
    && upx -9 bin/runner

FROM alpine:3.20 as runner

COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY --from=builder /www/bin/runner /www/runner

RUN echo "Asia/Shanghai" > /etc/timezone

WORKDIR /www

CMD ["/www/runner"]